/* 
 *  Syntelos XB
 *  Copyright (C) 2006 John Pritchard.
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License as
 *  published by the Free Software Foundation; either version 2 of
 *  the License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 *  02111-1307 USA
 */

package syntelos.xb.at;

/** 
 * 
 * 
 * @author jdp
 */
public final class Exceptions 
    extends syntelos.xb.Attribute
{
    public final static java.lang.String ATNAME = "Exceptions";
    public final static syntelos.iou.dom.Name NAME = new syntelos.iou.dom.impl.Name(ELEMENT_NODE,"http://www.syntelos.org/xb/at","xat:exceptions");
    
    public Exceptions(org.w3c.dom.Document doc, syntelos.iou.dom.Name name){
        super(doc,name);
    }
    public Exceptions(org.w3c.dom.Document doc){
        this(doc,NAME);
    }
    public Exceptions(){
        this(DOC_NIL);
    }

    public syntelos.iou.dom.Node compile(){

        this.getAttributeName().setNodeValue("utf8:Exceptions");

        return super.compile();
    }
    public int atlen(){
        int count = this.countChildNodes();
        return (2 + (2 * count));
    }
    public void readCF(syntelos.xb.IO.Uri src, syntelos.xb.CF.Reader reader)
        throws java.io.IOException
    {
        int at_length = reader.readInt();
        int count = reader.readUnsignedShort();
        syntelos.xb.Type.Class type;
        for (int cc = 0; cc < count; cc++){
            type = new syntelos.xb.Type.Class();
            this.appendChild(type);
            type.readCF(src,reader);
        }
    }
    public void writeCF(syntelos.xb.IO.Uri dst, syntelos.xb.CF.Writer writer)
        throws java.io.IOException
    {
        this.getAttributeName().writeCF(dst,writer);
        int at_len = this.atlen();
        writer.writeInt(at_len);
        int count = this.countChildNodes();
        writer.writeShort(count);
        if (0 < count){
            org.w3c.dom.NodeList children = this.getChildNodes();
            syntelos.xb.Type.Class type;
            for (int cc = 0; cc < count; cc++){
                type = (syntelos.xb.Type.Class)children.item(cc);
                type.writeCF(dst,writer);
            }
        }
    }
}
